//
//  AIGirlUserInfoViewController.swift
//  AIGirl
//
//  Created by Rae on 2023/12/27.
//

import UIKit

class AIGirlUserInfoNameViewController: AIGirlBaseViewController {

//    private lazy var backButton = c_make_ex(UIButton.self)
//        .image("AIGirl_Signin_back").end()
    private var sliderView = AIGirlMeansSliderView()
    private lazy var titleLabel = c_make_ex(UILabel.self)
        .color(.white).font(22.font_bold).alignment(.center)
        .text("Nice to meet you?").end()
    private var nameView = AIGirlNameView()
    
    private var currentIndex = 0
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false
        view.subviews{
//            backButton
            sliderView
            titleLabel
            nameView
        }
        
//        backButton.leading(15).top(.statusHeight).size(30)
        sliderView.leading(37.5).trailing(37.5).height(4.5).top(.statusHeight + 42.0)
        titleLabel.leading(15).trailing(15)
        titleLabel.Top == sliderView.Bottom + 55
        nameView.leading(0).trailing(0).bottom(0)
        nameView.Top == titleLabel.Bottom
        
        sliderView.value = 35
        nameView.title = "How do you prefer to be called?"
        nameView.placeholder = "create a username"
        nameView.nextClosure = { nameStr in
            
            self.request.start(.RegisterInfo(name: nameStr, age: 18, gender: 1)) { result in
                if result.isSuccessful {
                    UserDefaultsManager.setInt(2, forKey: .currentPage)
                    UserDefaultsManager.setString(nameStr, forKey: .userName)
                    self.navigationController?.pushViewController(AIGirlSetAgeViewController(), animated: true)
                }
            }
        }
    }
    

}
